import datetime
from applications.extensions import db


class Article(db.Model):
    __tablename__ = 'admin_article'
    id = db.Column(db.Integer, primary_key=True, comment="文章ID")
    category_id = db.Column(db.Integer, db.ForeignKey('admin_category.id'), comment="分类")
    title = db.Column(db.String(250), comment="标题")
    linkurl = db.Column(db.String(350), comment="外链")
    hitnum = db.Column(db.Integer, default=0, comment="点击量")
    sharenum = db.Column(db.Integer, default=0, comment="分享量")
    ip = db.Column(db.String(50), comment="IP")
    releaseuser = db.Column(db.Integer, comment="发布者")
    coverimg = db.Column(db.String(350), comment="封面图")
    lunbo = db.Column(db.Integer, default=0, comment="轮播")
    lunboimg = db.Column(db.String(350), comment="轮播图")
    sort = db.Column(db.Integer, default=0, comment="排序")  # -1代表类目置顶
    allsort = db.Column(db.Integer, default=0, comment="头条")
    literemark = db.Column(db.String(50), comment="摘要")
    author = db.Column(db.String(150), comment="作者")
    status = db.Column(db.Integer, default=0, comment='状态(1已审,0待审)')
    remark = db.Column(db.Text, comment="内容")
    release_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='发布时间')
    create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
    update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
